﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Visifire.Charts;

namespace SNAIL
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class UserControl1 : UserControl
    {
        public void ChangeValue(int InCount, int OutCount)
        {
            chart.Series.Clear();


            // Create a new instance of DataSeries
            DataSeries dataSeries = new DataSeries();

            // Set DataSeries property
            dataSeries.RenderAs = RenderAs.Bar;

            // Create a DataPoint
            DataPoint dataPoint, dataPoint2;


            // Create a new instance of DataPoint
            dataPoint = new DataPoint();

            // Set YValue for a DataPoint
            dataPoint.YValue = InCount;
            dataPoint.AxisXLabel = "Received";

            // Create a new instance of DataPoint
            dataPoint2 = new DataPoint();

            // Set YValue for a DataPoint
            dataPoint2.YValue = OutCount;
            dataPoint2.AxisXLabel = "Sent";
            // Add dataPoint to DataPoints collection.
            dataSeries.DataPoints.Add(dataPoint);
            dataSeries.DataPoints.Add(dataPoint2);



            // Add dataSeries to Series collection.
            chart.Series.Add(dataSeries);

        }

        // Create a new instance of Chart
        Chart chart = new Chart();
        public UserControl1()
        {
            InitializeComponent();

            chart.View3D = true;

            // Create a new instance of Title
            Title title = new Title();

            // Set title property
            title.Text = "";


            // Add title to Titles collection
            chart.Titles.Add(title);

            // Create a new instance of DataSeries
            DataSeries dataSeries = new DataSeries();

            // Set DataSeries property
            dataSeries.RenderAs = RenderAs.Bar;

            // Create a DataPoint
            DataPoint dataPoint, dataPoint2;


            // Create a new instance of DataPoint
            dataPoint = new DataPoint();

            // Set YValue for a DataPoint
            dataPoint.YValue = rand.Next(0, 100);
            dataPoint.AxisXLabel = "In";

            // Create a new instance of DataPoint
            dataPoint2 = new DataPoint();

            // Set YValue for a DataPoint
            dataPoint2.YValue = rand.Next(0, 100);
            dataPoint2.AxisXLabel = "Out";
            // Add dataPoint to DataPoints collection.
            dataSeries.DataPoints.Add(dataPoint);
            dataSeries.DataPoints.Add(dataPoint2);



            // Add dataSeries to Series collection.
            chart.Series.Add(dataSeries);

            // Add chart to LayoutRoot
            LayoutRoot.Children.Add(chart);
        }

        Random rand = new Random(DateTime.Now.Millisecond);
    }
}
